<template>
	<view class="">
		<scroll-view scroll-y="true">
			<view class="topBox">
				<view class="income-title" style="width: 390rpx;height: 54rpx;">
					<!-- <image style="width: 390rpx;height: 54rpx;" src="@/static/detail/logo.png"></image> -->
				</view>
				<view class="income-main">
					<view class="header">
						<text>
							<image style="width: 20rpx;height: 24rpx;margin-right: 10rpx;"
								src="@/static/detail/icon1.png" mode=""></image>
						</text>
						<text>资金安全有保障</text>
					</view>
					<view class="total-revenue">
						<view class="title">
							<text style="margin-right: 10rpx;">总收益(金豆)</text>
							<view v-if="show" @tap="show = false"><u-icon name="eye-fill"></u-icon></view>
							<view v-else @tap="show = true"><u-icon name="eye-off"></u-icon></view>
						</view>
						<view class="num">
							<text>{{show?iconInfo.totalIncome:'******'}}</text>
						</view>
					</view>
					<view class="revenue-details">
						<view class="">
							<view class="text">昨日收益(金豆)</view>
							<view class="num">{{iconInfo.yesterIncome}}</view>
						</view>
						<!-- <view class="">
							<view class="text">当月收益(元)</view>
							<view class="num">{{iconInfo.yesterIncome}}</view>
						</view> -->
						<view class="" @tap="jump('/pageA/wallet/wallet')">
							<view class="text">余额</view>
							<view class="num" style="display: flex;align-items: center;">
								<text>{{iconInfo.balance}}</text>
								<u-icon name="arrow-right" size="14" color="#000000"></u-icon>
							</view>
						</view>
					</view>
				</view>
				<!-- <view class="coinCount">
					<view class="num">
						{{iconInfo.day}}
					</view>
					<view class="text">
						参与天数
					</view>
				</view> -->
				<!-- <view class="countBox">
					<view class="countItem">
						<view class="num">
							{{iconInfo.totalIncome}}
						</view>
						<view class="text">
							累计收益(元)
						</view>
					</view>
					<view class="b">
						
					</view>
					<view class="countItem">
						<view class="num">
							{{iconInfo.yesterIncome}}
						</view>
						<view class="text">
						当月收益(元)
						</view>
					</view>
				</view> -->
			</view>
			<!-- <view class="profit_top">
				<view :class="day==7?'profit_b active':'profit_b'" @click="clickTab(7)">
					7天
				</view>
				<view  :class="day==15?'profit_b active':'profit_b'" @click="clickTab(15)">
					15天
				</view>
				<view  :class="day==30?'profit_b active':'profit_b'" @click="clickTab(30)">
					30天
				</view>
			</view> -->
			<!-- <view class="remind">
				<view class="left">
					<view class="">
						<image style="width: 96rpx; height: 72rpx;" src="@/static/index/species.png" mode=""></image>
					</view>
					<text>提现到账2341.3元 11天前</text>
				</view>
				<view class="">
					<u-icon name="arrow-right" size="16"></u-icon>
				</view>
			</view> -->
			<view class="profit_top">
				<!-- <view class="left">
					<view class="">流量收益</view>
					<view class="num">{{iconInfo.daymoney}}</view>
					<view class="image">
						<image style="width: 212rpx;height: 146rpx;" src="@/static/detail/property.png" mode=""></image>
					</view>
				</view>
				<view class="right">
					<view class="">流量数据</view>
					<view class="num">{{iconInfo.dayflow}}</view>
					<view class="image">
						<image style="width: 212rpx;height: 146rpx;" src="@/static/detail/flow.png" mode=""></image>
					</view>
				</view> -->
				<!-- <picker mode="date" fields="month" :end="newDay"   @change="clickTab">
					<view :class=" 'profit_b active'" >
						{{day}}
					</view>
				</picker> -->
				<!-- <view  :class="day==15?'profit_b active':'profit_b'" @click="clickTab(15)">
					15天
				</view>
				<view  :class="day==30?'profit_b active':'profit_b'" @click="clickTab(30)">
					30天
				</view> -->
			</view>
			<view class="content">
				<!-- <view class="charts-box">
							<l-f2 ref="chart"></l-f2>
						</view> -->
				<!-- 		<view class="profit_view">
							<view class="g">参与天数{{iconInfo.day}}天</view>
							<view class="r">昨日收益{{iconInfo.yesterIncome}}</view>
							<view class="r">累计收益{{iconInfo.totalIncome}}</view>
						</view> -->
				<view class="profit_list">
					<view class="profit_title">
						收益明细
					</view>
					<view class="profit_itemt">
						<view>日期</view>
						<view>设备收益</view>
						<view>推广收益</view>
						<!-- <view>渠道收益</view> -->
					</view>
					<view class="profit_item" v-for="(item,index) in iconInfo.list" :key="index"
						@click="jump(`./profitInfo?date=${item.date}`)">
						<view>{{item.date}}</view>
						<view>+{{item.flow}}</view>
						<view style="display: flex;align-items: center;">
							<view class="">+{{item.money}}</view>
							<image src="/static/newProject/equipment/icon_r.png" mode=""></image>
						</view>
						<!-- <view>
							<view>+{{item.point}}</view>
							
						</view> -->
					</view>
				</view>
			</view>
		</scroll-view>
		<!-- <view style="height: 170upx;">
			
		</view> -->
		<TabBar :tabBarShow="2"></TabBar>
	</view>
</template>

<script>
	// import F2 from '@antv/f2';
	// import F2 from '@antv/f2/dist/f2';
	export default {
		data() {
			return {
				show: true,
				iconInfo: {

				},
				lineData: [],
				day: '',
				newDay: '',
				// money: ''
			};
		},
		watch: {
			lineData() {
				this.xrDom()
			}
		},
		// 分享好友
		onShareAppMessage() {
			return {
				title: '云算能',
				path: JSON.parse(uni.getStorageSync('gitH5Qrcode')),
			}
		},
		// 分享朋友圈
		onShareTimeline() {
			return {
				title: '云算能',
				query: JSON.parse(uni.getStorageSync('gitH5Qrcode')),
			}
		},
		async onLoad() {
			this.day = this.$fun.getYMD()
			this.newDay = this.$fun.getYMD()
			// await this.$fun.ajax.post('user/balance', {}).then(res => {
			// 	if (res.code == 1) {
			// 		this.money = res.data.find(data => data.id === 2).money
			// 	}
			// })
		},
		onShow() {
			//模拟从服务器获取数据
			this.getServerData()
		},
		mounted() {
			// this.xrDom()
		},
		methods: {
			xrDom() {
				this.$refs.chart.init(config => {
					const chart = new F2.Chart(config);
					chart.source(this.lineData, {
						value: {
							tickCount: 5,
							min: 0
						},
						date: {
							type: 'timeCat',
							range: [0, 1],
							tickCount: 4,
							mask: 'MM-DD'
						}
					});
					chart.tooltip({
						custom: true,
						showXTip: true,
						showYTip: true,
						snap: true,
						crosshairsType: 'xy',
						crosshairsStyle: {
							lineDash: [1]
						}
					});
					chart.axis('date', {
						label: function label(text, index, total) {
							const textCfg = {
								stroke: '#999999'
							};
							if (index === 0) {
								textCfg.textAlign = 'left';
							} else if (index === total - 1) {
								textCfg.textAlign = 'right';
							}
							return textCfg;
						}
					});
					chart.line().position('date*value').color('#1E84F1').size(1.2);
					chart.render();
					return chart;
				});
			},
			clickTab(e) {
				this.day = e.detail.value
				this.chartsDataLine1 = []
				this.getServerData()
			},
			jump(url) {
				this.$fun.jump(url)
			},
			getServerData() {
				let data = []
				this.$fun.ajax.post('product/incomeList', {
					day: this.day
				}).then(res => {
					this.iconInfo = res.data
					this.$fun.setArr(res.data.kline.date, res.data.kline.flow)
				})
			}
		}
	};
</script>

<style lang="scss">
	page {
		background: #F5F9FF;
		background: url('/static/index/imgbgc.png') no-repeat;
		background-size: 100% 100%;
		height: 100%;
	}

	.topBox {
		position: relative;
		// background: linear-gradient(#1E84F1, #fff);
		height: 500rpx;
		padding: 30rpx;
		line-height: 1.5;

		// overflow: hidden;
		.income-title {
			// margin-top: 100rpx;
		}

		.income-main {
			position: absolute;
			z-index: 99;
			left: 30rpx;
			// top: 200rpx;
			right: 30rpx;
			height: 330rpx;
			background: #FFFFFF;
			border-radius: 20rpx 20rpx 20rpx 20rpx;

			.header {
				// text-align: center;
				font-size: 24rpx;
				font-family: PingFang SC, PingFang SC;
				font-weight: 400;
				color: #1E84F1;
				height: 50rpx;
				background-color: rgba(120, 210, 196, .5);
				display: flex;
				align-items: center;
				justify-content: center;
				border-radius: 20rpx 20rpx 0 0;

				image {}
			}

			.total-revenue {
				text-align: center;
				margin: 28rpx 0;

				.title {
					display: flex;
					justify-content: center;
					align-items: center;
				}

				.text {
					font-size: 28rpx;
					font-family: PingFang SC, PingFang SC;
					font-weight: 400;
					color: #5e5e5e;
				}

				.num {
					font-size: 46rpx;
					font-family: PingFang SC, PingFang SC;
					font-weight: 600;
					color: #000;
				}
			}

			.revenue-details {
				display: flex;
				justify-content: space-between;
				padding: 0 40rpx;
				text-align: center;

				.text {
					font-size: 24rpx;
					font-family: PingFang SC, PingFang SC;
					font-weight: 400;
					color: #5e5e5e;
				}

				.num {
					font-size: 28rpx;
					font-family: PingFang SC, PingFang SC;
					font-weight: 600;
					color: #232323;
				}

			}
		}

		.coinCount {
			margin-top: 50rpx;
			text-align: center;

			.num {
				font-size: 54rpx;
				font-family: Bahnschrift;
				font-weight: 600;
				color: #FFFFFF;
			}

			.text {
				font-size: 24rpx;
				font-family: Adobe Heiti Std;
				font-weight: normal;
				color: #EEEEEE;
			}
		}

		.countBox {
			margin-top: 50rpx;
			display: flex;
			justify-content: space-between;
			align-items: center;

			.countItem {
				width: calc((100% - 2rpx)/2);
				text-align: center;

				.num {
					font-size: 40rpx;
					font-family: Bahnschrift;
					font-weight: 600;
					color: #FFFFFF;
				}

				.text {
					font-size: 24rpx;
					font-family: Adobe Heiti Std;
					font-weight: normal;
					color: #EEEEEE;
				}
			}

			.b {
				width: 2rpx;
				height: 60rpx;
				background: #FFFFFF;
				opacity: 0.33;
			}
		}
	}

	.remind {
		background-color: #fff;
		margin: 60rpx 30rpx 0;
		display: flex;
		align-items: center;
		justify-content: space-between;
		padding: 0 15rpx;
		border-radius: 8rpx 8rpx 8rpx 8rpx;

		.left {
			display: flex;
			align-items: center;
			font-size: 24rpx;
			font-family: PingFang SC, PingFang SC;
			font-weight: 400;
			color: #232323;
		}

	}

	.profit_top {
		display: flex;
		justify-content: space-between;
		padding: 0 30rpx;
		margin-top: 28rpx;

		.left {
			width: 340rpx;
			height: 282rpx;
			background: linear-gradient(180deg, #FFE6E7 0%, #FFFFFF 100%);
			border-radius: 8rpx 8rpx 8rpx 8rpx;
			opacity: 1;
			padding: 28rpx;
			font-size: 28rpx;
			font-family: PingFang SC, PingFang SC;
			font-weight: 400;
			color: #5e5e5e;
			position: relative;

			.num {
				font-size: 38rpx;
				font-weight: 600;
				margin-top: 22rpx;
				color: #232323;
			}

			.image {
				position: absolute;
				bottom: -20rpx;
				right: 10rpx;
			}
		}

		.right {
			width: 340rpx;
			height: 282rpx;
			background: linear-gradient(180deg, #CBDFFE 0%, #FFFFFF 100%);
			border-radius: 8rpx 8rpx 8rpx 8rpx;
			opacity: 1;
			padding: 28rpx;
			font-size: 28rpx;
			font-family: PingFang SC, PingFang SC;
			font-weight: 400;
			color: #5e5e5e;
			position: relative;

			.num {
				font-size: 38rpx;
				font-weight: 600;
				margin-top: 22rpx;
				color: #232323;
			}

			.image {
				position: absolute;
				bottom: -20rpx;
				right: 10rpx;
			}
		}
	}

	.content {
		display: flex;
		flex-direction: column;
		flex: 1;
		// background: #FFFFFF;

		.charts-box {
			width: calc(100% - 18rpx*2);
			height: 634rpx;
			margin: 0 auto;
			padding-right: 30rpx;
			background: #FFFFFF;
			border-radius: 12rpx;
		}

		.profit_view {
			height: 100rpx;
			display: flex;
			align-items: center;
			justify-content: space-between;
			background: #FFFFFF;
			padding: 0 30rpx;
			box-sizing: border-box;
			font-size: 30rpx;
			font-family: Microsoft YaHei;
			font-weight: 400;
			color: #333333;

			.g {
				color: #333333;
			}

			.r {
				color: #1E84F1;
			}
		}

		.profit_list {
			margin: 24rpx 18rpx;
			background: #FFFFFF;
			border-radius: 12rpx;

			.profit_title {
				padding-top: 32rpx;
				padding-left: 32rpx;
				font-size: 28rpx;
				font-family: Source Han Sans CN;
				font-weight: bold;
				color: #333333;
			}

			.profit_itemt {
				margin-top: 30rpx;
				height: 80rpx;
				// background: #F6F6F6;
				display: flex;
				justify-content: space-between;
				border-radius: 10rpx 10rpx 0rpx 0rpx;
				align-items: center;

				view {
					width: 25%;
					text-align: center;
					font-size: 24rpx;
					font-family: Source Han Sans CN;
					font-weight: 400;
					color: #999999;
				}

				view:not(:nth-child(1)) {
					text-align: left;
				}
			}

			.profit_item {
				height: 100rpx;
				// background: #FFFFFF;
				display: flex;
				justify-content: space-between;
				border-radius: 10rpx 10rpx 0rpx 0rpx;
				align-items: center;
				font-size: 28rpx;
				font-family: Source Han Sans CN;
				font-weight: 400;
				color: #333333;

				view {
					display: flex;
					justify-content: space-between;
					width: 25%;
					font-size: 30rpx;
					font-family: Microsoft YaHei;
					color: #FF0000;
					text-align: center;

					image {
						width: 14rpx;
						height: 24rpx;
						margin-right: 20rpx;
					}
				}

				view:nth-child(1) {
					width: 25%;
					color: #333333;
					display: flex;
					justify-content: center;
				}

				view:not(:nth-child(1)) {
					width: 25%;
					text-align: left;
					color: #1E84F1;
				}
			}
		}
	}
</style>